<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>多个数组求交集</title>
</head>
<body>
  <!-- 每个数组中都出现的数字 -->
  <script>
    function fn(nums) {
      let res = new Array(1000 + 10).fill(0);
      for (let i of nums) {
        for (let num of i) {
          res[num]++
        }
      }
      return res.map((val, idx) => val === nums.length ? idx : 0).filter(val => val !== 0)
    }
    console.log(fn([[1, 2, 3], [4, 5, 6]]))
  </script>
</body>
</html>